 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
require_once "include/function.php";
connect_db();
class wish{
	private $userid,$deleteid;
	public function setuserid($userid){
		
		$sql_str=	"SELECT * FROM users u WHERE u.status=1 and u.username ='".$userid."'";
		//echo $sql_str;
		//exit;
	    $result = mysql_query($sql_str);
		while($row = mysql_fetch_array($result))
		{
			$userid=$row["u_id"];
		}
	$this->userid=$userid;
	}	
	public function setdeleteid($deleteid){
	$this->deleteid=$deleteid;
	}
		
	public function deletewish()
	{
		$sql_str=	"Delete from wishlist where w_id =".$this->deleteid." ;" ;
		//echo $sql_str;
		//exit;
		$result = mysql_query($sql_str);
		/*echo "<script type='text/javascript' > alert('".$this->deleteid."');</script>";*/
		echo "<script type='text/javascript' > alert('ลบข้อมูลในเรียบร้อยแล้ว');</script>";
		
			
		
		
	}
		/*$sql_str = "select * 
		from 
			(wishlist wl
				LEFT JOIN wishlist_set wls ON wl.w_set_id = wls.w_set_id)
			,venders v ,
			(((product p
				LEFT JOIN product_rate pr ON p.p_id = pr.p_id)
			LEFT JOIN
				product_file pf ON p.p_id = pf.p_id)
			LEFT JOIN
				categories_sub cs ON p.cat_id = cs.cat_id)
			
		where 
			wl.u_id='".$this->userid."' and wl.p_id=p.p_id and v.v_id=p.v_id;";
			*/
public function showwishcommon()
	{
		
		
	
		$sql_str=	"SELECT * FROM wishlist w ,product p,users u,wishlist_set ws WHERE p.p_id = w.p_id and u.u_id=w.u_id and u.u_id='".$this->userid."' and w.w_set_id =ws.w_set_id and p_status=1 order by w_id";
		
		//echo $sql_str;
		//exit;
		$irow=0;
		$result = mysql_query($sql_str);
		echo "<table border='3' width='700'>";
		echo "<tr><td>ลำดับ</td><td>ชื่อ</td>";
			echo "<td>ราคา</td>";
			echo "<td>ชนิด</td>";
			echo "<td>ลบสินค้า</td>";
			//echo "<td>Delete</td><td><input name='Delete' type='submit' value='".$row["w_id"] . "'></td>";
			echo "</tr>";
		while($row = mysql_fetch_array($result))
		{
			$irow++;
			echo "<tr><td>" . $irow . "</td><td>".$row["p_name"]."</td>";
			echo "<td>".$row["p_price"]."</td>";
			echo "<td>".$row["w_set_name"]."</td>";
			echo "<td>
			<form method='post' action='wishlist.php?w_id=".$row['w_id'] . "' >
			
    <input name='Delete' type='submit' value='Delete'></form></td>";
			echo "</tr>";
			//echo "<tr><td>download</td><td><a href='book/".$row["bookid"].".pdf'>download</a></td></tr></table><br><br><br>";
			
		}
		echo "</table><br><br><br>";
		//<form action=\"OrderAction.php?pro_id=".$row['pro_id']."\" method=\"post\"><input type=\"text\" name=\"price\" value=\"1\"><input type=\"submit\" value=\"Buy\"></form></td></tr>";
		//<input type='hidden' name='hidden' id='hiddenField' 
    //value='".$row['w_id'] . "'>
		//echo "<form action='showall.php' method='post'  >";
			//echo "<input name='showall' type='button'>";
			//echo "</form>";
	}
/*
public function show()
	{	
	while($row = mysql_fetch_array($result))
	{
?>
  <tr>
    <td><?php echo $row["cus_id"];?></td>
    <td><?php echo $row["firstname"];?></td>
    <td><?php echo $row["surname"];?></td>
    <td><?php echo $row["address"];?></td> 
    <td><?php echo $row["username"];?></td>
    <td><?php echo $row["password"];?></td> 

	<td>
    <form method="post" action="RegisterAction.php" >
    <input type="hidden" name="hidden" id="hiddenField" 
    value="<?php echo $row['cus_id'];?>">
    <input name="Delete" type="submit" value="Delete">
    
    </form>
    </td>
  </tr>
  
<?php
	}
	}//end show
*/
}//end class
?>